<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('record/index')}">积分记录列表</a></li>
        <li class="active"><a href="{:url('record/add')}">添加积分记录</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form margin-top-20" action="{:url('record/add')}" method="post">
        <div class="form-group">
            <label for="student_id" class="col-sm-2 control-label">学校</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="" id="selectSchool">
                    <option value="">请选择学校</option>
                    <foreach name="school" item="vo">
                        <option value="{$vo.id}">{$vo.name}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="student_id" class="col-sm-2 control-label">班级</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="" id="selectRoom">
                    <option value="">请选择班级</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="student_id" class="col-sm-2 control-label">学生姓名</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="stu_id" id="student_id">
                    <option value="">请选择学生</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="reason_id" class="col-sm-2 control-label">原因</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="reason_id" id="reason_id">
                    <option value="" selected>请选择原因</option>
                    <foreach name="reason" item="vo">
                        <option value="{$vo.id}">{$vo.name}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="score_id" class="col-sm-2 control-label">积分</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="score_id" id="score_id">
                    <option value="" selected>请选择原因</option>
                    <foreach name="score" item="vo">
                        <option value="{$vo.id}">{$vo.name}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">积分截图:</label>
            <div class="col-md-6 col-sm-10">
                <input id="photo-1" type="hidden" name="image" >
                <input id="photo-1-name" type="text" name="photo_name" title="图片名称">
                <img id="photo-1-preview" width="50px">
                <a href="javascript:uploadOneImage('图片上传','#photo-1');">上传</a>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit" id="sub">添加</button>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js">
</script>
<script>
    $(function () {
        $('#selectSchool').change('click',function () {
            var schoolId = $('#selectSchool').val();
            $.ajax({
                url: "{:url('record/getRoombySchool')}",
                type: "POST",
                data: {school_id:schoolId},
                success: function (res) {
                    $('#selectRoom').html(res);
                }
            })
        })
    })

</script>
<script>
    $(function () {
        $('#selectRoom').change('click',function () {
            var roomId = $('#selectRoom').val();
            $.ajax({
                url: "{:url('record/getRoombyStudent')}",
                type: "POST",
                data: {room_id:roomId},
                success: function (res) {
                    $('#student_id').html(res);
                    form.render();
                }
            })
        })
    })
</script>
</body>
</html>